package demo.jmockit;

import mockit.Mock;
import mockit.MockUp;
import org.junit.Assert;
import org.junit.Test;

public class DemoTest {
    @Test
    public void testClassMockingByExpectation() {
        new MockUp<Demo>() {
            @Mock
            public int staticMethod() {
                return 10;
            }
            @Mock
            public int ordinaryMethod() {
                return 20;
            }
            @Mock
            public final int finalMethod() {
                return 30;
            }
            @Mock
            private int privateMethod() {
                return 40;
            }
        };
        Demo demo = new Demo();
        System.out.println(demo.staticMethod());
        System.out.println(demo.ordinaryMethod());
        System.out.println(demo.finalMethod());
        System.out.println(demo.callPrivateMethod());
        Assert.assertTrue(demo.staticMethod() == 10);
        Assert.assertTrue(demo.ordinaryMethod() == 20);
        Assert.assertTrue(demo.finalMethod() == 30);
        Assert.assertTrue(demo.callPrivateMethod() == 40);
    }

}
